#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	int t;
	cin >> t;
	while (t--) {
		string s;
		cin >> s;
		set<char> st;
		for (auto i : s)
			st.insert(i);
		if (st.size() == 1)
			cout << "NO" << endl;
		else {
			cout << "YES" << endl;
			string t = s;
			sort(t.begin(), t.end());
			do {
				if (t != s) {
					cout << t << endl;
					break;
				}
			} while (next_permutation(t.begin(), t.end()));
		}
	}
	return 0;
}
